Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reduce block interval poc #265

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

will-2012
Copy link
Contributor

@will-2012 will-2012 commented Feb 28, 2025

Description

Reduce block interval poc.

Notice: This is a draft PR, a work in progress, and not ready for review.

Rationale

TBD

Example

TBD

Changes

Notable changes:

  • TBD

@will-2012 will-2012 marked this pull request as draft February 28, 2025 04:26
@will-2012 will-2012 added the WIP label Feb 28, 2025
@will-2012 will-2012 force-pushed the reduce_block_interval_poc branch 4 times, most recently from 6f6c827 to 01d6315 Compare February 28, 2025 07:01
@will-2012 will-2012 force-pushed the reduce_block_interval_poc branch 21 times, most recently from baa5440 to bf3372a Compare February 28, 2025 13:35
@will-2012 will-2012 force-pushed the reduce_block_interval_poc branch 5 times, most recently from 7da7fa8 to bff700d Compare March 1, 2025 08:32
@will-2012 will-2012 force-pushed the reduce_block_interval_poc branch from bff700d to 8520a2f Compare March 1, 2025 09:35
@flywukong flywukong force-pushed the reduce_block_interval_poc branch from 95b03d8 to d1eb66f Compare March 3, 2025 11:13
@flywukong flywukong force-pushed the reduce_block_interval_poc branch from 3c284e5 to a717b8c Compare March 3, 2025 12:55
@@ -43,11 +45,18 @@ func WatchHeadChanges(ctx context.Context, src NewHeadSource, fn HeadSignalFn) (
for {
select {
case header := <-headChanges:
var mTime uint64
if header.MixDigest == (common.Hash{}) {
mTime = header.Time
Copy link
Contributor Author

@will-2012 will-2012 Mar 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is mTime not initialized to 0?

@flywukong flywukong force-pushed the reduce_block_interval_poc branch from a20bd64 to 618dbe0 Compare March 4, 2025 06:18
d.CancelBuildingBlock(ctx)
return nil, err
} else if errors.Is(err, derive.ErrTemporary) {
d.log.Error("sequencer failed temporarily to seal new block", "err", err)
d.nextAction = d.timeNow().Add(time.Second)
d.nextAction = d.timeNow().Add(backoffTime)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original semantics was to backoff for one second, not necessarily the interval of the block. Why did this change the semantics?

// We don't explicitly cancel block building jobs upon temporary errors: we may still finish the block.
// Any unfinished block building work eventually times out, and will be cleaned up that way.
} else {
d.log.Error("sequencer failed to seal block with unclassified error", "err", err)
d.nextAction = d.timeNow().Add(time.Second)
d.nextAction = d.timeNow().Add(backoffTime)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@@ -362,11 +362,18 @@ func (s *channelManager) AddL2Block(block *types.Block) error {
}

func l2BlockRefFromBlockAndL1Info(block *types.Block, l1info *derive.L1BlockInfo) eth.L2BlockRef {
milliPart := uint64(0)
Copy link
Collaborator

@joeylichang joeylichang Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L2BlockRef as the l2BlockRefFromBlockAndL1Info return value, it is only used to mertics, so it is useless for adding the milliPart.

@joeylichang
Copy link
Collaborator

joeylichang commented Mar 7, 2025

It is most important for op-batcher that adda millsecondes into RawSpanBatch, then sends to L1, and op-node can parser the millsecondes form L1 BlobData. But it is missing.

PrevRandao: eth.Bytes32(l1Info.MixDigest()),
SuggestedFeeRecipient: predeploys.SequencerFeeVaultAddr,
Transactions: txs,
NoTxPool: true,
GasLimit: (*eth.Uint64Quantity)(&sysConfig.GasLimit),
Withdrawals: withdrawals,
ParentBeaconBlockRoot: parentBeaconRoot,
}, nil
}
pa.SetMillisecondTimestamp(nextL2MilliTime)
Copy link
Collaborator

@joeylichang joeylichang Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetMillisecondTimestamp(common.hash, millseconds) -> set millseconds to first common.hash.

then the return value to init eth.PayloadAttributes in 173 line, may be better.

@@ -96,7 +96,7 @@ func (bq *BatchQueue) NextBatch(ctx context.Context, parent eth.L2BlockRef) (*Si
if len(bq.nextSpan) > 0 {
// There are cached singular batches derived from the span batch.
// Check if the next cached batch matches the given parent block.
if bq.nextSpan[0].Timestamp == parent.Time+bq.config.BlockTime {
if bq.nextSpan[0].Timestamp == parent.MillisecondTimestamp()+bq.config.MillisecondBlockInterval() {
Copy link
Collaborator

@joeylichang joeylichang Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the Timestamp is changed to milliseconds for seconds, add one note that it is active after hard fork, otherwise it is seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants